<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">

<!--数据双向绑定-->
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>


<body>
<div id="main" v-cloak>
    <!--做一个两个数值的加减乘除-->
    <input type = "text" v-model="num1">
    <select v-model="opt">
        <option value="+">+</option>
        <option value="-">-</option>
        <option value="*">*</option>
        <option value="/">/</option>
    </select>
    <input type ="text" v-model="num2">
    <input type ="button" value="=" @click="btn">
    <input type ="text" v-model="result">
</div>



<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    var vm = new Vue({
        el: '#main',
        data: {
            msg: 'Hello Vue',
            num1:'',
            num2:'',
            result:'',
            opt:'+'
        },
        methods:{
            btn(){
                <!--如果想在method里面调用data数据，一定要用this-->
                switch (this.opt){
                    case '+':parseInt(this.num1)+parseInt(this.num2)
                        break;
                    
                }
            }
        }

    })
</script>

</body>
</html>